#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n = 0, count = 0;
    cin >> n;
    vector<long long> A(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> A[i];
        if (A[i] == 0)
            ++count;
    }
    vector<vector<long long>> dp(n + 1, vector<long long>(n + 1));

    for (int i = 1; i <= n; ++i)
        dp[i][i] = A[i-1];

    for (int i = n - 1; i > 0; --i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            dp[i][j] = A[i-1] + A[j-1] + dp[i + 1][j - 1];
            if (dp[i][j] == 0)
                ++count;
        }
    }

    cout << count << "\n";
    return 0;
}